import { http } from '@/utils/http'

/**
 * 【分页列表查询】查询讨论区帖子 discussion列表
 * @param params
 * @returns 讨论区列表
 */
export function getCommentListApi(params?: any) {
  return http.get<any>('/edu/discussion/list', params)
}

/**
 * 【新增发帖】新增讨论区帖子 discussion
 * @param data
 * @returns void
 */
export function addDiscussionData(data: any) {
  return http.post<void>('/edu/discussion', data)
}

/**
 * 修改讨论区帖子
 * @param data
 * @returns void
 */
export function updateDiscussionData(data: any) {
  return http.put<void>('/edu/discussion', data)
}

/**
 * 【新增发帖】新增讨论区帖子评论 discussion
 * @param data
 * @returns void
 */
export function addDiscussionComment(data: any) {
  return http.post<void>('/edu/discussionComment', data)
}

/**
 * 【分页列表查询】查询评论
 * @param params
 * @returns 查询评论列表
 */
export function getDiscussionComment(params?: any) {
  return http.get<any>('/edu/discussionComment/list', params)
}

/**
 * 获取讨论区帖子 discussion详细信息
 * @param id id
 * @returns
 */
export function getRowData(id: number | string) {
  return http.get<any>(`/edu/discussion/${id}`)
}

/**
 * 【新增点赞】新增讨论区帖子 discussion
 * @param data
 * @returns void
 */
export function addLike(data: any) {
  return http.post<void>('/edu/discussionLike', data)
}

/**
 * 取消点赞
 * @param id id
 */
export function cancelLike(params) {
  return http.delete<void>(`/edu/discussionLike/deleteByIdAndType`, params)
}

/**
 * 获取当前帖子点赞数量
 * @param id id
 * @returns
 */
export function getLikes(discussionId: number | string) {
  return http.get<any>(`/edu/discussionLike/count/${discussionId}`)
}

/**
 * 删除讨论区帖子 discussion
 * @param id id
 */
export function deleteDiscussion(id: string | number) {
  return http.delete<void>(`/edu/discussion/delete/${id}`)
}

/**
 * 新增讨论贴主题
 * @param data
 * @returns void
 */
export function addThemeApi(data: any) {
  return http.post<void>('/edu/discussionTopic', data)
}

/**
 * 查询讨论贴主题列表
 * @param id id
 * @returns
 */
export function getThemeApi(params: any) {
  return http.get<any>(`/edu/discussionTopic/list`, params)
}

/**
 * 查询定位
 * @param
 * @returns
 */
export function getUserAddress(params: any) {
  return http.get<any>(`/edu/get-address-by-jwd`, params)
}

/**
 * 消息通知【小铃铛】是否有红点
 * @param
 * @returns
 */
export function hasNewMsgYnAPi() {
  return http.get<any>(`/edu/app/discussion/countByDiscussionId`)
}
